package com.google.gwt.maps.v3.sample.client.presenter;

import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.maps.v3.client.HasMap;
import com.google.gwt.maps.v3.client.base.HasLatLng;
import com.google.gwt.maps.v3.client.base.LatLng;
import com.google.gwt.maps.v3.client.streetview.HasStreetViewPanorama;
import com.google.gwt.maps.v3.client.streetview.HasStreetViewPanoramaOptions;
import com.google.gwt.maps.v3.client.streetview.HasStreetViewPov;
import com.google.gwt.maps.v3.client.streetview.StreetViewPanorama;
import com.google.gwt.maps.v3.client.streetview.StreetViewPanoramaOptions;
import com.google.gwt.maps.v3.client.streetview.StreetViewPov;
import com.google.gwt.maps.v3.sample.client.Constant;
import com.google.gwt.maps.v3.sample.client.view.SampleView;
import com.google.gwt.user.client.Element;

public class StreetViewSimplePresenter implements Presenter<StreetViewSimplePresenter.Display> {

  public static interface Display extends SampleView {
    Element getPanoContainer();
    HasMap getMap();
  }
  
  final private Display display;
  final private String presenterLink;
  final private String viewLink;
  
  public StreetViewSimplePresenter(final Display display) {
    super();
    this.display = display;
    presenterLink = Constant.SOURCE_URL_PREFIX
        + this.getClass().getName().replace('.', '/') + ".java";
    viewLink = Constant.SOURCE_URL_PREFIX
        + display.getClass().getName().replace('.', '/') + ".java";
  }

  @Override
  public void bind() {
    display.setPresenterLink(presenterLink);
    display.setViewLink(viewLink);
    
    HasLatLng fenway = new LatLng(42.345573, -71.098326);
    HasStreetViewPov pov = new StreetViewPov();
    HasStreetViewPanoramaOptions panoramaOptions = new StreetViewPanoramaOptions();
    panoramaOptions.setPosition(fenway);
    pov.setHeading(34);
    pov.setPitch(10);
    pov.setZoom(1);
    panoramaOptions.setPov(pov);
    HasStreetViewPanorama panorama = new StreetViewPanorama(display.getPanoContainer(), panoramaOptions);
    display.getMap().setStreetView(panorama);
  }

  @Override
  public Display getDisplay() {
    return display;
  }

  @Override
  public HandlerManager getEventBus() {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public void release() {
    // TODO Auto-generated method stub
    
  }
}
